package cn.samler.account_manager.validator;

import cn.samler.account_manager.annotation.InAccountFailedMap;
import cn.samler.account_manager.model.SearchType;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class InAccountFailedMapCheck implements ConstraintValidator<InAccountFailedMap, Integer> {
    @Override
    public void initialize(InAccountFailedMap constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(Integer type, ConstraintValidatorContext constraintValidatorContext) {
        if (type == null) {
            return false;
        }

        return SearchType.FAILED_MAP.containsKey(type);
    }
}
